<template>
<view class="all">
   <!-- 我的账户 -->
   <view class="myAccount">
      <view class="myAccountTitle">我的账户</view>
      <view class="myAccountNav">
         <view>
            <image src="/static/remao_shop/img/mySell.png"></image>
            <text>余额</text>
         </view>
         <view>￥{{moneyList}}</view>
      </view>
   </view>
   <!-- 充值金额 -->
   <view class="rechargeNum">
      <view class="myAccountTitle">充值金额</view>
      <view class="rechargeNumNav">
         <view v-for="(item, index) in combo" :key="index" @tap="xzShow" :data-gid="index" :class="'rechargeNumNavLists ' + (num==index?'rechargeNumNavList':'rechargeNumNavLists')">
            <view>{{item.rechargeamount}}</view>
            <view style="font-size:26rpx;color:#757575">送{{item.donationamount}}</view>
         </view>
      </view>
      <view class="rechargeNow">立即充值</view>
   </view>
   <!-- 充值说明 -->
   <view class="explain">
      <view class="myAccountTitle">充值说明</view>
      <rich-text class="wenz" :nodes="smList"></rich-text>
   </view>
</view>
</template>

<script>
// hotmall/packageA/recharge/recharge.js
var app = getApp();
import api from "../../../api";

export default {
  data() {
    return {
      uid: '',
      moneyList: '0.00',
      combo: [],
      id: '192',
      smList: [],
      num: 0
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    wx.getStorage({
      key: 'userId',
      success: res => {
        console.log(res);
        this.setData({
          uid: res.data
        });
        this.getList();
        this.smListFun();
      }
    });
    this.setData({
      moneyList: options.moneyList
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.smListFun();
    this.getList();
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
    //充值金额套餐
    getList: function () {
      app.globalData.request({
        url: api.default.packages_index,
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        data: {
          uid: this.uid
        },
        method: 'POST',
        success: res => {
          console.log(res);
          this.setData({
            combo: res.packages_list
          });
        }
      });
    },
    //充值说明
    smListFun: function () {
      app.globalData.request({
        url: api.default.article_about,
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        data: {
          uid: this.uid,
          id: this.id
        },
        method: 'POST',
        success: res => {
          console.log(res);
          this.setData({
            smList: res.article_info.content
          });
        }
      });
    },
    //选中加样式
    xzShow: function (event) {
      console.log(event.currentTarget.dataset.gid);
      this.setData({
        num: 0
      });
      this.setData({
        num: event.currentTarget.dataset.gid
      });
    }
  }
};
</script>
<style>
@import "./recharge.css";
</style>